﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<SDT.Admin.ViewModels.DepartmentEditViewModel>" %>
<%@ Import Namespace="SDT.Lib.Helpers" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Sửa
</asp:Content>
<asp:Content ID="Content7" ContentPlaceHolderID="Header" runat="server">
	Bộ phận
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="Toolbar" runat="server">
	<%= Html.Toolbar("Xóa", string.Format("/Department/Delete/{0}", Model.Department.ID), "delete")%>
	<%= Html.Toolbar("Quay lại", "/Department", "back")%>
</asp:Content>

<asp:Content ID="Content6" ContentPlaceHolderID="Message" runat="server">
    <%=ViewData["MessageInfo"]!=null? "<p class='perror'>"+Html.Encode(ViewData["MessageInfo"])+"</p>":string.Empty%> 
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<%if(ViewData["MessageInfo"]==null){ %>
    <% using (Html.BeginForm("Edit", "Department", FormMethod.Post, new { id = "adminForm" } )) {%>
        <%= Html.ValidationSummary(true) %>     
        <fieldset>
            <legend>Sửa</legend>
			<font color="red">*</font> là trường bắt buộc phải nhập.
			<table class="admintable">
				<tbody><tr>
					<td class="key">Đơn vị (<font color="red">*</font>)</td>
					<td><%=Html.DropDownList("ParentID", new SelectList(Model.ParrentOrganizations, "ID", "Name", Model.Department.ParentID).ToList(), "-- Chọn đơn vị --", new { @class = "title" })%></td>
				</tr>
				<tr>
					<td class="key">Tên bộ phận (<font color="red">*</font>)</td>
					<td>
						<%= Html.TextBox("Name", Model.Department.Name, new { @class = "required title", maxlength = 250 })%>
					</td>
				</tr>
				<tr>
					<td class="key">Mô tả</td>
					<td>
						<%= Html.TextArea("Description", Model.Department.Description, new { rows = 4, @class = "description" })%>
					</td>
				</tr>
				<tr>
					<td colspan="2" align="center"><input type="submit" value="Lưu" /></td>
				</tr></tbody>
			 </table>
        </fieldset>
		<%= Html.Hidden("ID", Model.Department.ID)%>
    <% } %>
    <script type="text/javascript">
		$(document).ready(function() {
			$("#adminForm").validate({
				rules: {
					Name: "required"
				},
				messages: {
					Name: "Trường này là bắt buộc, vui lòng nhập dữ liệu!" 
				}
			});
		});
	</script>
<% } %>
</asp:Content>
